// V-backend/src/routes/cart.js
const express = require('express');
const router = express.Router();
const cartController = require('../controllers/cartController');
const { auth } = require('../middleware/auth');  // 修复这里

// 所有购物车接口都需要认证
router.get('/', auth, cartController.getUserCart);
router.get('/count', auth, cartController.getCartCount); // 新增数量接口
router.post('/add', auth, cartController.addToCart);
router.put('/:cart_id', auth, cartController.updateCartItem);
router.delete('/:cart_id', auth, cartController.removeFromCart);
router.delete('/', auth, cartController.clearCart);

module.exports = router;